# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-apps/ucspi-ssl/ucspi-ssl-0.70-r1.ebuild,v 1.17 2012/11/06 08:12:14 ulm Exp $

inherit eutils fixheadtails qmail

DESCRIPTION="Command-line tools for building SSL client-server applications."
HOMEPAGE="http://www.fehcom.de/ipnet/ucspi-ssl.html"
SRC_URI="http://www.fehcom.de/ipnet/ucspi-ssl/${P}.tgz"

LICENSE="public-domain"
SLOT="0"
KEYWORDS="amd64 x86"
IUSE="perl tls"

DEPEND=">=dev-libs/openssl-0.9.6g
	sys-apps/ucspi-tcp"
RDEPEND="${DEPEND}"

S="${WORKDIR}"/host/superscript.com/net/${P}/src

src_unpack() {
	unpack ${A}
	cd "${S}"

	ht_fix_all
	sed -i -e 's:HOME/command:/usr/bin:' sslcat.sh sslconnect.sh https\@.sh
	sed -i -e 's:auto:gcc:' conf-cc conf-ld

	local ldarch
	case "${ARCH}" in
		x86)	ldarch="-m32" ;;
		amd64)	ldarch="-m64" ;;
	esac
	sed -i -e "s:-m64:${ldarch}:" conf-ld

	qmail_set_cc

	echo "/usr/bin" > conf-tcpbin
	echo "/usr/" > home
	echo "/usr/share/ca-certificates/" > conf-cadir
	echo "${QMAIL_HOME}/control/dh1024.pem" > conf-dhfile
}

src_compile() {
	make || die "make failed"
}

src_install() {
	dodoc ../doc/*
	doman ../man/*.*
	dobin sslserver sslclient sslcat sslconnect https\@ || die
	use perl && dobin sslperl
}
